<!DOCTYPE html>

<html>
<head>
	<title>OO js with MooTools</title>
	<script type="text/javascript" src="mootools-core-1.3.js" charset="utf-8"></script>
	<script type="text/javascript" src="mootools-more.js" charset="utf-8"></script>


</head>

<body>


</body>
	<script type="text/javascript" charset="utf-8">
	/*passage d'arguments au constructeur*/
		var Human = new Class({
			/*Default properties*/
			Sexe:"",
			Name:"John Doe",
			Age:0,
			Father : {},
			
			initialize:function(name,age){
				//if(arguments.length==2){
					this.Name = name;
					this.Age = age;
					//this.Father = new Human("Father of "+name);
				//}
			},
			
			grow:function(){
				this.Age++;
			}
			
		});
		
		var Bob = new Human("Bob");
		//Bob.Name = "Bob";
		Bob.grow(); Bob.grow(); Bob.grow();
		
		console.log(Bob.Name+' is '+Bob.Age+' year(s) old');
		
		var Sam = new Human('Sam le pirate', 40);
		Sam.grow(); Sam.grow();
		console.log(Sam.Name+' is '+Sam.Age+' year(s) old');
		
		Bob.Father = new Human("Father of "+Bob.Name);
		Sam.Father = new Human("Father of "+Sam.Name);
		
		
		console.log(Bob.Father.Name);
		console.log(Sam.Father.Name);
		
		
	</script>
</html>
